class Solution {
     public int findMin2(int[] nums) {
         int min = nums[0];
         for (int i = 1; i < nums.length; i++) {
             if (nums[i] < min) {
                 min = nums[i];
             }
         }
         return min;
     }

     public int findMin3(int[] nums) {
         int left = 0;
         int right = nums.length-1;
         // 选择nums.length-1当作标准
         int target = nums[nums.length-1];
         while (left < right) {
             int mid = left + (right-left) / 2;
             if (nums[mid] > target) {
                 left = mid+1;
             } else {
                 right = mid;
             }
         }
         return nums[left];
     }


    public int findMin(int[] nums) {
        int left = 0;
        int right = nums.length-1;
        // 选择0当作标准
        int target = nums[0];
        while (left < right) { // 这个只适合有断层的数据
            int mid = left + (right-left) / 2;
            if (nums[mid] >= target) {
                left = mid+1;
            } else {
                right = mid;
            }
        }
        // 当数组本身是有序时，上面的方法不适合
        return nums[left] > nums[0] ? nums[0] : nums[left];
    }
}